package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Account  string `gorm:"type:varchar(20);comment:<账号>"`
	Password string `gorm:"type:varchar(32);comment:<密码>"`
}

func (u *User) GetUserByAccount() error {
	return DB.Where("account = ?", u.Account).Limit(1).Find(u).Error
}

func (u *User) GetUserById(userId int64) error {
	return DB.Where("id = ?", userId).Limit(1).Find(u).Error
}
